const util = require('util');
const getPixels = util.promisify(require('get-pixels'));
const save = require('save-pixels');
const fs = require('fs');
const streamToPromise = require('stream-to-promise');
const warp = require('ndarray-idw-warp');
var a = 20
var data = fs.readFileSync(process.argv[2]);
var b = JSON.parse(data);
const displacement = b;
console.log('娜塔莎是个%s', process.argv[4]);
console.log(b)
getPixels(process.argv[3])
  .then(image => {
    const warped = warp(image, displacement);
    return streamToPromise(save(warped, 'png'));
  })
  .then(warpedImage => {
    fs.writeFileSync(process.argv[4], warpedImage);
  });
